package cn.edu.zut.service.Impl;

import cn.edu.zut.dao.AwardsDao;
import cn.edu.zut.domain.AwardsInfo;
import cn.edu.zut.service.AwardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AwardServiceImpl implements AwardService {
    @Autowired
    private AwardsDao awardsDao;

    @Override
    public void add(AwardsInfo awardsInfo){
        awardsDao.add(awardsInfo);
    }
    @Override
    public void update(AwardsInfo awardsInfo){
        awardsDao.update(awardsInfo);
    }
    @Override
    public void deleteByUserId(int id){ awardsDao.deleteByUserId(id); }
    @Override
    public List<AwardsInfo> findAll() {
        return awardsDao.findAll();
    }
    @Override
    public AwardsInfo findByUserId(int id){
        return awardsDao.findByUserId(id);
    }
    @Override
    public AwardsInfo findBySTNumberAndContestAndAward(String STNumber, String contestName, String awardLevel){
        return awardsDao.findBySTNumberAndContestAndAward(STNumber,contestName,awardLevel);
    }
    @Override
    public List<AwardsInfo> findLikeByPrint(String STNumber, String contestName, String awardLevel){
        return awardsDao.findLikeByPrint(STNumber,contestName,awardLevel);
    }
    @Override
    public List<AwardsInfo> findBySTNumber(String STNumber){
        return awardsDao.findBySTNumber(STNumber);
    }
    @Override
    public List<AwardsInfo> findByContestName(String contestName){
        return awardsDao.findByContestName(contestName);
    }

    @Override
    public int findEmptyId(){
        List<AwardsInfo> list=awardsDao.findAll();
        for(int i=0;i<list.size();i++){
            if(list.get(i).get_id()!=i)return i;
        }
        return list.size();
    }

    @Override
    public List<AwardsInfo> findAllByPrint(AwardsInfo awardsInfo) {
        return awardsDao.findAllByPrint(awardsInfo);
    }
}
